home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / QuickDraw 3D / Samples / SampleCode / BoxPaint+ - non stereo / sources / BoxPaint_menu.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-14  |  5.2 KB  |  257 lines  |  [TEXT/CWIE]

  1. /*  menu.c                                                                            
  2.  
  3.     This contains all the menu code.
  4.                                                                                     
  5.     Michael Bishop - August 21 1996                                                    
  6.     Nick Thompson
  7.     (c)1994-96 Apple computer Inc., All Rights Reserved                                
  8.  
  9. */
  10.  
  11. /* --------------------------------------------------------------------
  12. ** Includes
  13. */
  14.  
  15. #include    <StandardFile.h>
  16. #include    <Devices.h>
  17.  
  18. #include    "BoxPaint_menu.h"
  19. #include    "BoxPaint_utility.h"
  20. #include    "BoxPaint_window.h"
  21. #include    "BoxPaint_document.h"
  22. #include    "BoxPaint_main.h"
  23.  
  24. #include    "QD3DAcceleration.h"
  25.  
  26.  
  27. /* --------------------------------------------------------------------
  28. ** Global Variables
  29. */
  30.  
  31.  
  32. /* --------------------------------------------------------------------
  33. ** Local Functions
  34. */
  35.  
  36.  
  37. /*    --------------------------------------------------------------------
  38. **    Menu_Adjust
  39. **    Update the menus to reflect the current status of the App
  40. */
  41. void Menu_Adjust( void ) 
  42. {
  43.     DocumentHdl            theDocument;
  44.     long                theResolution;
  45.     MenuHandle            theMenu;
  46.     WindowPtr            theWindow = FrontWindow();
  47.     
  48.  
  49.     if (theWindow != NULL) {
  50.     
  51.         theDocument = Window_GetDocument(theWindow);
  52.  
  53.         if(theDocument != NULL)    {
  54.  
  55.             /*    TextureResolution Menu    */
  56.             theResolution = Texture_GetResolution(Document_GetTexture(theDocument));
  57.  
  58.             theMenu = GetMenuHandle(mResolution);
  59.  
  60.             if (theResolution == 64)
  61.                 CheckItem(theMenu, i64, true);
  62.             else
  63.                 CheckItem(theMenu, i64, false);
  64.  
  65.             if (theResolution == 128)
  66.                 CheckItem(theMenu, i128, true);
  67.             else
  68.                 CheckItem(theMenu, i128, false);
  69.  
  70.             if (theResolution == 256)
  71.                 CheckItem(theMenu, i256, true);
  72.             else
  73.                 CheckItem(theMenu, i256, false);
  74.             
  75.             /*    Renderer Menu    */
  76.             {
  77.                 long    theVendorID, theEngineID;
  78.                 
  79.                 Document_GetRendererPreferences(theDocument, &theVendorID, &theEngineID);
  80.                 
  81.                 theMenu = GetMenuHandle(mRenderer);
  82.  
  83.                 if (theVendorID == kQAVendor_BestChoice)
  84.                 {
  85.                     CheckItem(theMenu, iBest, true);
  86.                 }
  87.                 else
  88.                 {
  89.                     CheckItem(theMenu, iBest, false);
  90.                 }
  91.  
  92.                 if (theEngineID == kQAEngine_AppleHW)
  93.                     CheckItem(theMenu, iHardware, true);
  94.                 else
  95.                     CheckItem(theMenu, iHardware, false);
  96.  
  97.                 if (theEngineID == kQAEngine_AppleSW)
  98.                     CheckItem(theMenu, iSoftware, true);
  99.                 else
  100.                     CheckItem(theMenu, iSoftware, false);
  101.             }
  102.         }
  103.     }
  104. }
  105.  
  106.  
  107. /*    --------------------------------------------------------------------
  108. **    Menu_HandleCommand
  109. **    Finds out what was selected and does something about it.
  110. */
  111. void Menu_HandleCommand(long menuResult)
  112. {
  113.     short                menuID;
  114.     short                menuItem;
  115.     Str255                daName;
  116.     MenuHandle            theMenu;
  117.     
  118.     DocumentHdl            theDocument;
  119.  
  120.     short                numTypes = 1 ;
  121.     SFTypeList            myTypes = { '3DMF', 0 } ;
  122.     
  123.  
  124.     WindowPtr            theWindow = FrontWindow() ;
  125.             
  126.     theDocument = Window_GetDocument(theWindow);
  127.  
  128.     menuID = Utility_HiWrd(menuResult);
  129.     menuItem = Utility_LoWrd(menuResult);
  130.     
  131.     switch ( menuID ) {
  132.         /*  */
  133.         /* --------------------------------------------------------------------------     */
  134.         /*  */
  135.         case mApple:
  136.             switch ( menuItem ) {
  137.  
  138.                 case iAbout:
  139.                     Main_DoAbout() ;    
  140.                     break ;
  141.                                 
  142.                 default:
  143.                     GetMenuItemText(GetMenuHandle(mApple), menuItem, daName);
  144.                     (void) OpenDeskAcc(daName);
  145.                     break;
  146.             }
  147.             break;
  148.         /* --------------------------------------------------------------------------     */
  149.         case mFile:
  150.             switch ( menuItem ) {
  151.             
  152.                 case iNew:
  153.                     Document_New() ;
  154.                     break ;
  155.                 
  156.                 case iOpen:
  157.                     Document_Open(Document_New()) ;
  158.                     break ;
  159.  
  160.                 case iSave:    
  161.                     Document_Save( Window_GetDocument(theWindow) ) ;
  162.                     break ;
  163.                 
  164.                 case iSaveAs:
  165.                     break;                
  166.                 
  167.                 case iClose:
  168.                     Document_Dispose( Window_GetDocument(theWindow) ) ;
  169.                     break ;
  170.                     
  171.                 case iQuit:
  172.                     gQuitFlag = true ;
  173.                     break;
  174.             }
  175.             break;
  176.             
  177.             
  178.         /* --------------------------------------------------------------------------     */
  179.         case mEdit:
  180.  
  181.             switch(menuItem)
  182.             {
  183.                 case iCut:
  184.                     break;
  185.                 case iCopy:
  186.                     break;
  187.                 case iPaste:
  188.                     break;
  189.                 case iClear:
  190.                     break;
  191.                 default:
  192.                     break;
  193.             }
  194.             break; 
  195.  
  196.         /* --------------------------------------------------------------------------     */
  197.         case mResolution:
  198.  
  199.         if (theWindow != NULL)
  200.             switch(menuItem)
  201.                 {
  202.                     case i64:
  203.                     Document_Remap(Window_GetDocument(theWindow), 64);
  204.                         break;
  205.                     case i128:
  206.                     Document_Remap(Window_GetDocument(theWindow), 128);
  207.                         break;
  208.                     case i256:
  209.                     Document_Remap(Window_GetDocument(theWindow), 256);
  210.                         break;
  211.                     default:
  212.                         break;
  213.                 }
  214.                 break; 
  215.  
  216.         /* --------------------------------------------------------------------------     */
  217.         case mRenderer:
  218.  
  219.         if (theWindow != NULL)
  220.         {
  221.             long    theVendorID, theEngineID;
  222.             Document_GetRendererPreferences(theDocument, &theVendorID, &theEngineID);
  223.                 
  224.             theMenu = GetMenuHandle(mRenderer);
  225.             
  226.             switch(menuItem)
  227.                 {
  228.                     case iSoftware:
  229.                         theEngineID = kQAEngine_AppleSW;
  230.                         break;
  231.                     case iHardware:
  232.                         theEngineID = kQAEngine_AppleHW;
  233.                         break;
  234.                     case iBest:
  235.                     if ( theVendorID == kQAVendor_Apple)
  236.                         theVendorID = kQAVendor_BestChoice;
  237.                     else
  238.                         theVendorID = kQAVendor_Apple;
  239.                         break;
  240.                     default:
  241.                         break;
  242.                 }
  243.  
  244.             Document_SetRendererPreferences(theDocument, theVendorID, theEngineID);
  245.  
  246.             HLock((Handle)theDocument);
  247.             Document_Draw(*theDocument);
  248.             HUnlock((Handle)theDocument);
  249.         }
  250.         break; 
  251.  
  252.     }
  253.     HiliteMenu(0);        /*  Unhighlight whatever MenuSelect or MenuKey hilited */
  254. }
  255.  
  256.  
  257.